<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <input class="nav-checkbox" type="checkbox" id="toggle">
  <label class="nav-label" for="toggle">
    <i class="icon-menu"></i>
  </label>

  <style>
    .nav-checkbox {
      display: none;
    }

    .nav-label {
      width: 72px;
      height: 72px;
      display: flex;
      justify-content: center;
      align-items: center;
      border: 1px solid red;
    }

    #toggle:checked~[for="toggle"] .icon-menu {
      transform: rotate(-180deg);
    }

    #toggle:checked~[for="toggle"] .icon-menu:before,
    #toggle:checked~[for="toggle"] .icon-menu:after {
      width: 45px;
      right: -10px;
    }

    #toggle:checked~[for="toggle"] .icon-menu:before {
      top: -13px;
      transform: rotate(45deg);
    }

    #toggle:checked~[for="toggle"] .icon-menu:after {
      bottom: -13px;
      transform: rotate(-45deg);
    }
  </style>

  <style>
    html,
    body {
      width: 100%;
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      margin: 0;
      background-color: rgb(3, 2, 12);
    }

    .icon-menu,
    .icon-menu:before,
    .icon-menu:after {
      display: block;
      width: 50px;
      height: 8px;
      background-color: #0000FF;
      transition: all 1s;
    }

    .icon-menu {
      position: relative;
    }

    .icon-menu:before,
    .icon-menu::after {
      position: absolute;
      margin: 0;
      content: "";
    }

    .icon-menu::before {
      top: -24px;
    }

    .icon-menu::after {
      bottom: -24px;
    }
  </style>
</body>

</html>